<?php
/**
 * Introduction: 支付
 * @author: 杨陈鹏
 * @date: 2016/4/7 23:00
 * @email: yangchenpeng@cdlinglu.com
 */

namespace WeChat\Controller\Pay;


use Common\Controller\WeChat\SignController;
use Think\Alipay\Alipay;
use Think\Wxpay\Wxpay;

class IndexController extends SignController
{
    /**
     * Introduction: 支付
     * @author: 杨陈鹏
     * @date: 2016/4/7 23:00
     * @email: yangchenpeng@cdlinglu.com
     */
    public function index()
    {


        $order_id = I('param.order_id');

        $code = I('param.code');

        $order_logic = D('Common/Order','Logic');

        if(!$order_id)
            outPut(['code' => 300,'msg' => '缺少订单信息!']);

        if(!$code)
            outPut(['code' => 300,'msg' => '缺少code!']);

        //检测库存
        $check = $order_logic::checkStorage($order_id);

        if($check['code'] == 300)
            outPut($check);

        $order = $order_logic::calcOrderTotalPrice($order_id);

        $order_info['order_sn']                 = $order['data']['number'];
        $order_info['buyer_name']               = '您在'.C('SMS_CONFIG.SMS_API_SIGN').'的交易订单号为:'.$order['data']['number'].'。交易时间:'.date('Y-m-d H:i:s');
        $order_info['order_amount']               = intval($order['data']['total']);

        $pay = new \Think\Wxpay\Wxpay();

        outPut($pay->WeChatPay($order_info,$code));

    }


}